package com.gxa.insurance.controller;

import com.gxa.insurance.pojo.Order;
import com.gxa.insurance.service.OrderService;
import com.gxa.insurance.service.RemoteOrderService;
import com.gxa.insurance.util.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @ClassName RemoteOrderController
 * @Description TODO
 * @Author ds
 * @Date 2022/6/13 12:37
 * @Version 1.0
 */
@Api
@RestController
@RequestMapping("/remoteOrder")
@CrossOrigin
public class RemoteOrderController {

    @Autowired
    OrderService orderService;

    @Autowired
    RemoteOrderService remoteOrderService;

    @ApiOperation(value = "更新异地委托函详情订单",produces = "body")
    @ApiImplicitParam(
            name = "map",value = "传参示例"+"{\n" +
            "\t\"orderId\":\"id\",\n" +
            "\t\"number\":\"20181043022\",\n" +
            "\t\"orderType\":\"异地委托函\",\n" +
            "\t\"creatTime\":\"2020:12:12 12:12:12\",\n" +
            "\t\"orderStatus\":\"待确认\",\n" +
            "\t\"isMakeCompemsation\":\"是\",\n" +
            "\t\"isSendMessage\":\"是\",\n" +
            "\t\"attention\":\"特定事项\",\n" +
            "\t\"messageCus\":\"客户短信内容\",\n" +
            "\t\"messageDri\":\"司机短信内容\",\n" +
            "\t\"contactPerson\":\"张三\",\n" +
            "\t\"contactPhone\":\"18113490553\",\n" +
            "\t\"carId\":\"川X888888\",\n" +
            "\t\"images\":\"123456.jpg\",\t\n" +
            "}"
    )
    @PostMapping("/update")
    public Map update(@RequestBody Map<String,String> map) throws Exception {
        remoteOrderService.update(map);

        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("200");
        jsonResult.setMsg("更新成功");


        return jsonResult.getMap();
    }

    @ApiOperation(value = "根据订单编号获取支付编号,支付状态",produces = "query")
    @ApiImplicitParam(name = "orderNumber",value = "订单编号")
    @PostMapping("/getPayNumber")
    public Map getPayNumber(String orderNumber) throws Exception {
        List<Order> payNumber = orderService.getPayNumber(orderNumber);

        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("200");
        jsonResult.setMsg("获取成功");
        jsonResult.setData(payNumber);

        return jsonResult.getMap();
    }
}
